package com.boc.ewr.util.file.enumeration;

import lombok.extern.slf4j.Slf4j;

import java.util.Arrays;
import java.util.Optional;

/**
 * 签约发送渠道
 */
@Slf4j
public enum SignSendChannelEnum {
    ONLINE("1", "网银(单一)"),
    MAIL("2", "邮寄(单一)");

    private String index;
    private String value;

    SignSendChannelEnum(String index, String value){

        this.index = index;
        this.value = value;
    }

    /**
     * 根据value获取枚举对象
     *
     * @param val
     * @return
     */
    public static SignSendChannelEnum getIndexByValue(String val) {
        Optional<SignSendChannelEnum> first = Arrays.stream(SignSendChannelEnum.values()).filter(e -> e.getValue().equals(val)).findFirst();
        SignSendChannelEnum expEnum = first.orElse(null);
        log.info("选择的枚举类型是：" + expEnum.toString());
        return expEnum;
    }

    public String getIndex() {
        return index;
    }

    public void setIndex(String index) {
        this.index = index;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

}
